package cn.elwy.kit.maven;

import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;

import cn.elwy.kit.file.service.FileRename;

public class MavenHandleDialog extends TitleAreaDialog {
  private FileRename fileRename;
  private Text text;
  private Table table;
  private Text text_1;

  /**
   * Create the dialog.
   * @param parentShell
   */
  public MavenHandleDialog(Shell parentShell) {
    super(parentShell);
    fileRename = new FileRename();
  }

  /**
   * Create contents of the dialog.
   * @param parent
   */
  @Override
  protected Control createDialogArea(Composite parent) {
    setTitle("Maven安装Jar");
    setMessage("部署jar包到服务器或者本地");
    Composite area = (Composite) super.createDialogArea(parent);
    Composite container = new Composite(area, SWT.NONE);
    GridLayout gl_container = new GridLayout(1, false);
    container.setLayout(gl_container);
    container.setLayoutData(new GridData(GridData.FILL_BOTH));

    TabFolder tabFolder = new TabFolder(container, SWT.NONE);
    tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    TabItem tbtmNewItem = new TabItem(tabFolder, SWT.NONE);
    tbtmNewItem.setText("New Item");

    Composite composite = new Composite(tabFolder, SWT.NONE);
    tbtmNewItem.setControl(composite);
    composite.setLayout(new GridLayout(3, false));

    Label lblNewLabel = new Label(composite, SWT.NONE);
    lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblNewLabel.setText("New Label");

    text = new Text(composite, SWT.BORDER);
    text.setText(
        "mvn install:install-file -Dfile=${file} -DgroupId=${groupId} -DartifactId=${artifactId} -Dversion=${version} -Dpackaging=jar");
    text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

    Label lblNewLabel_1 = new Label(composite, SWT.NONE);
    lblNewLabel_1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblNewLabel_1.setText("New Label");

    text_1 = new Text(composite, SWT.BORDER);
    text_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Button btnNewButton = new Button(composite, SWT.NONE);
    btnNewButton.setText("New Button");

    ToolBar toolBar = new ToolBar(composite, SWT.FLAT | SWT.RIGHT);
    toolBar.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));

    ToolItem toolItem = new ToolItem(toolBar, SWT.NONE);
    toolItem.setText("添加文件夹");

    ToolItem tltmNewItem = new ToolItem(toolBar, SWT.NONE);
    tltmNewItem.setText("添加文件");

    ToolItem toolItem_1 = new ToolItem(toolBar, SWT.NONE);
    toolItem_1.setText("删除");
    new Label(composite, SWT.NONE);

    table = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION);
    table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    return area;
  }

  /**
   * Create contents of the button bar.
   * @param parent
   */
  @Override
  protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
  }

  @Override
  protected void okPressed() {
  }

  /**
   * Return the initial size of the dialog.
   */
  @Override
  protected Point getInitialSize() {
    return new Point(700, 500);
  }
}
